XML Basics - Part 3


Elements are delimited using tags, which consist of the element type name (a string literal) enclosed within a pair of angle brackets(< >). Every element must be bound by a start tag and an end tag (also known as opening tag and closing tag). In the code example below, <symbol> is a start tag, and </symbol> is an end tag. Unlike HTML, XML requires that a end tag be used for every element.

It's important to distinguish between the tag set that delimits an element and the element itself. In the code below, <symbol> isn't the element; the entire line - including both tags and the character data AAPL - is the element, known as a document component.

Certain elements may not have any content. In XML, an element with a single tag is called an empty element. Empty elements end with /> (see below <market />)

<?xml version="1.0"?><order transaction="buy">   <symbol>AAPL</symbol>   <quantity>500</quantity>   <market/>   <status>pending</status></order>

A document containing one or more elements is well-formed. The parser determines if it can extract data structures from a document by examining the number of elements in it. A document lacking elements has no data structures; a document with at least one element has data structure.

Copyright 2000 Extensibility, Inc.

Suite 250, 200 Franklin Street, Chapel Hill, North Carolina 27516